package com.monkeygroup.mygoplus.view.home.activity.sell;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.HorizontalScrollView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.facebook.drawee.view.SimpleDraweeView;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.GoogleMapOptions;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.monkeygroup.mygoplus.R;
import com.monkeygroup.mygoplus.base.BaseActivity;
import com.monkeygroup.mygoplus.commit.thing.vo.PropertyCommitVO;
import com.monkeygroup.mygoplus.common.utils.LocalInfo;
import com.monkeygroup.mygoplus.common.utils.StringUtil;
import com.monkeygroup.mygoplus.http.PersonHttpModel;
import com.monkeygroup.mygoplus.http.RequestUrl;
import com.monkeygroup.mygoplus.http.ThingsHttpModel;
import com.monkeygroup.mygoplus.thing.vo.MyImageVO;
import com.monkeygroup.mygoplus.thing.vo.RentVO;
import com.monkeygroup.mygoplus.thing.vo.UserVO;
import com.monkeygroup.mygoplus.view.home.activity.ThingsDetailActivity;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.assist.FailReason;
import com.nostra13.universalimageloader.core.display.RoundedBitmapDisplayer;
import com.nostra13.universalimageloader.core.listener.ImageLoadingListener;



import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by cumt on 2017/6/9.
 */

public class ThingsCarportDetailActivity extends BaseActivity implements OnMapReadyCallback {


    public static void gotoActivity(Activity activity, String type, String parent, String modal, String carport) {

        Intent intent = new Intent(activity,
                ThingsCarportDetailActivity.class);

        Bundle bundle = new Bundle();
        bundle.putSerializable("param", "");
        intent.putExtra("param", bundle);

        //1-租房，2-出售
        intent.putExtra("type", type);
        intent.putExtra("parent", parent);
        //
        intent.putExtra("modal", modal);
        intent.putExtra("carport", carport);

        activity.startActivityForResult(intent, 3);
    }

    private TextView txt_top,txtTitle, txtImgSize, txtPurpose, txtName, txtContact, txtAddr, txtSalePriceTitle,
            txtSaleprice, txtAreaTitlie, txtArea, txtStoreyTitle, txtStorey, txtCarpotHaveTitel, txtCarpotHave,
            txtLiftTitle, txtLift, txtFeeTitle, txtFee, txtFittingTitle, txtFitting, txtCompletedateTitle,
            txtCompletedate, txtTypeTitle, txtType, txtDirectionTitle, txtDirection, txtCommunityNameTitle,
            txtCommunityName;

    private LayoutInflater mInflater;

    private HorizontalScrollView scrollView;
    private LinearLayout linear;

    private List<MyImageVO> imageVO;
    private RentVO rentVO;
    private LinearLayout layout_shortcut;
    //請求
    private ThingsHttpModel httpThingsModel,httpThingsModel1;

    private ViewPager viewPager;
    private ImageView[] mImageViews;
    ImageLoader loader;
    DisplayImageOptions options;

    private String type,parent,modal,carpot;

    private RentVO propertyModel;

    //請求參數
    private Map<String, String> params;
    private PersonHttpModel personHttpModel;
    private StringBuffer url;
    private  PropertyCommitVO vo = null;
    private String param1;

    @Override
    public void setContentView() {
        setContentView(R.layout.activity_sell_carport_detail);
        mInflater = LayoutInflater.from(this);
        SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
                .findFragmentById(R.id.map);
        mapFragment.getMapAsync(this);
    }

    @Override
    public void initView() {

//        layout_shortcut= (LinearLayout) findViewById(R.id.layout_shortcut);
//        layout_shortcut.setVisibility(View.INVISIBLE);
        txtTitle = (TextView) findViewById(R.id.txt_title);
        txtTitle.setText("出售物件");
        txt_top = (TextView) findViewById(R.id.txt_top);
        txt_top.setText("发布");

        txtImgSize = (TextView) findViewById(R.id.viewPager_things_all);
        txtPurpose = (TextView) findViewById(R.id.text_things_detail_purpose);
        txtName = (TextView) findViewById(R.id.text_things_detail_name);
        txtContact = (TextView) findViewById(R.id.text_detail_contact);
        txtAddr = (TextView) findViewById(R.id.text_detail_addr);
        txtSalePriceTitle = (TextView) findViewById(R.id.text_things_detail_saleprice_title);
        txtSaleprice = (TextView) findViewById(R.id.text_things_detail_saleprice);
        txtAreaTitlie = (TextView) findViewById(R.id.text_things_detail_area_title);
        txtArea = (TextView) findViewById(R.id.text_things_detail_area);
        txtStoreyTitle = (TextView) findViewById(R.id.text_things_detail_storey_title);
        txtStorey = (TextView) findViewById(R.id.text_things_detail_storey);
        txtCarpotHaveTitel = (TextView) findViewById(R.id.text_things_detail_cartport_have_title);
        txtCarpotHave = (TextView) findViewById(R.id.text_things_detail_cartport_have);
        txtLiftTitle = (TextView) findViewById(R.id.text_things_detail_lift_title);
        txtLift = (TextView) findViewById(R.id.text_things_detail_lift);
        txtFeeTitle = (TextView) findViewById(R.id.text_things_detail_fee_title);
        txtFee = (TextView) findViewById(R.id.text_things_detail_fee);
        txtFittingTitle = (TextView) findViewById(R.id.text_things_detail_fitting_title);
        txtFitting = (TextView) findViewById(R.id.text_things_detail_fitting);
        txtCompletedateTitle = (TextView) findViewById(R.id.text_things_detail_completeyear_title);
        txtCompletedate = (TextView) findViewById(R.id.text_things_detail_completeyear);
        txtTypeTitle = (TextView) findViewById(R.id.text_things_detail_type_title);
        txtType = (TextView) findViewById(R.id.text_things_detail_type);
        txtDirectionTitle = (TextView) findViewById(R.id.text_things_detail_direction_title);
        txtDirection = (TextView) findViewById(R.id.text_things_detail_direction);
        txtCommunityNameTitle = (TextView) findViewById(R.id.text_things_detail_communityname_title);
        txtCommunityName = (TextView) findViewById(R.id.text_things_detail_communityname);

        scrollView = (HorizontalScrollView) this.findViewById(R.id.horizontal_scrollView_things);
        linear = (LinearLayout) this.findViewById(R.id.linearlayout_things_scrollView);

        Intent intent = this.getIntent();
        Bundle bundle =  intent.getExtras();
        type = bundle.getString("type");
        parent= bundle.getString("parent");
        modal= bundle.getString("modal");
        carpot= bundle.getString("carport");

        String param = (String) getIntent().getBundleExtra("param").getSerializable("param");
        imageVO = (List<MyImageVO>) getIntent().getBundleExtra("param").getSerializable("imgModel");
        propertyModel = (RentVO) getIntent().getBundleExtra("param").getSerializable("propertyModel");
//        userVO = (UserVO) getIntent().getBundleExtra("param").getSerializable("userVO");
        if(StringUtil.isBlank(param)){

            url=new StringBuffer(RequestUrl.savepropertyUrl);

            propertyModel = new RentVO();
            propertyModel.setLat(0);
            propertyModel.setLng(0);

            if("2".equals(type)){
                //車位
                 if("5".equals(parent)){
                     Log.e("modalcarpot",modal+"==="+carpot+"::"+type+parent);
                     vo=LocalInfo.getCarportProperty(ThingsCarportDetailActivity.this,modal,carpot);
                     vo.setProperty_sale(1);
                }
            }
            else if("1".equals(type)){

                vo=LocalInfo.getRentCarportProperty(ThingsCarportDetailActivity.this,modal,carpot);
                vo.setProperty_rent(1);
                Log.e("modalmodal222==",vo.getProperty_purpose()+"==="+modal+"=="+carpot);
            }
            String imgtype="";
            //圖片
            if(vo.getPropertyimg_sceimgtype()!=null){
                for(int i=0;i<vo.getPropertyimg_sceimgtype().length;i++){
//                Log.e("getPropertyie==",""+vo.getPropertyimg_sceimgtype()[i]);
                    if(!StringUtil.isBlank(vo.getPropertyimg_sceimgtype()[i])){
                        imgtype=vo.getPropertyimg_sceimgtype()[i];
                    }
                }
                if(vo.getPropertyimg_path1()!=null){

                    for(int i=0;i<vo.getPropertyimg_path1().length;i++) {
                        if (!StringUtil.isBlank(vo.getPropertyimg_path1()[i])) {
                            if(i==0){
                                url.append("?propertyimg_sceimgtype[]="+imgtype);
                            }
                            else{
                                url.append("&propertyimg_sceimgtype[]="+imgtype);
                            }

                            url.append("&propertyimg_path1[]="+vo.getPropertyimg_path1()[i]);
                            url.append("&propertyimg_path3[]="+vo.getPropertyimg_path1()[i]);
                            url.append("&propertyimg_path4[]="+vo.getPropertyimg_path1()[i]);
                            url.append("&propertyimg_width[]="+vo.getPropertyimg_width()[i]);
                            url.append("&propertyimg_height[]="+vo.getPropertyimg_height()[i]);
                            url.append("&propertyimg_size[]="+vo.getPropertyimg_size()[i]);
                            url.append("&propertyimg_name[]="+vo.getPropertyimg_name()[i]);

                        }
                    }
                }

                for(int i=0;i<vo.getPropertyimg_sceimgtype().length;i++) {
                    if (!StringUtil.isBlank(vo.getPropertyimg_sceimgtype()[i])) {



                    }
                }
            }

            getThingsInfo(vo);


            params = new HashMap<String, String>();
            vo.toMap(params);
            txt_top.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {


                    personHttpModel.requestUserLogin();
                }
            });
            param1 = "?area="+String.valueOf(vo.getProperty_area())+"&modal="+vo.getProperty_modal();

        }
        else{
            initDetailRequest(param);
            httpThingsModel.requestThings();
             param1 = "?area="+propertyModel.getArea()+"&modal="+propertyModel.getModal();
        }


        initHorizontalScrollViewRequest(param1);
        httpThingsModel1.requestThings();


    }

    @Override
    public void setListener() {

    }

    @Override
    public void doEvent() {

    }

    public void initHorizontalScrollViewRequest(String param) {
        httpThingsModel1 = new ThingsHttpModel(RequestUrl.thingsbuyUrl + param,
                new ThingsHttpModel.SimpleOnHttpRequestListener() {
                    @Override
                    public void onRequestFinished(String resultCode, Integer timestamp) {

                    }

                    @Override
                    public void onRequestFinished(String resultCode, Object property, Object user, Object users, Object circuit, Object img) {
                        Gson gson = new Gson();
                        List<RentVO> propertys = gson.fromJson(gson.toJson(property), new TypeToken<List<RentVO>>() {
                        }.getType());

                        for (int i = 0; i < propertys.size(); i++) {
                            if(propertys.get(i).getSeq()==propertyModel.getSeq()){
                                continue;
                            }
                            createChildLinearLayout(propertys.get(i),i);
                        }

                    }

                    @Override
                    public void onBuildingRequestFinished(String resultCode, Object building, Object user, Object users, Object circuit, Object img) {

                    }

                    @Override
                    public void onCommunityRequestFinished(String resultCode, Object community, Object user, Object users, Object circuit, Object img) {

                    }
                }, true);


        personHttpModel = new PersonHttpModel(url.toString(),params,new PersonHttpModel.SimpleOnHttpRequestListener(){


            @Override
            public void onRequestFinished(String resultCode, Integer timestamp) {

            }

            @Override
            public void onRequestFinished(String resultCode, int seq, int isbind, String acc) {


            }

            @Override
            public void onRequestFinished(String resultCode, int seq, int flag, String flag_name, int secflag, String secflag_name) {

                Log.e("resultCoderesultCode===",""+"ERROR_OK".equals(resultCode));
                //請求成功
                if("ERROR_OK".equals(resultCode)){
                    Toast.makeText(ThingsCarportDetailActivity.this, "发布成功",
                            Toast.LENGTH_SHORT).show();
                    txt_top.setVisibility(View.INVISIBLE);
                    LocalInfo.removeProperty(ThingsCarportDetailActivity.this,vo);

                }
                else{

                    Toast.makeText(ThingsCarportDetailActivity.this, "发布失败",
                            Toast.LENGTH_SHORT).show();
                }
            }

        },true);


    }

    public void initDetailRequest(String param) {
        httpThingsModel = new ThingsHttpModel(RequestUrl.getPropertyUrl + param,
                new ThingsHttpModel.SimpleOnHttpRequestListener() {
                    @Override
                    public void onRequestFinished(String resultCode, Integer timestamp) {

                    }

                    @Override
                    public void onRequestFinished(String resultCode, Object property, Object user, Object users, Object circuit, Object img) {
                        Gson gson = new Gson();
                        List<MyImageVO> imgModel = gson.fromJson(gson.toJson(img), new TypeToken<List<MyImageVO>>() {
                        }.getType());
                         propertyModel = gson.fromJson(gson.toJson(property), new TypeToken<RentVO>() {
                        }.getType());
                        UserVO userVO = gson.fromJson(gson.toJson(user), new TypeToken<UserVO>() {
                        }.getType());
                        setImage(imgModel);
                        setThingsInfo(propertyModel);
                        setUserInfo(userVO);
                    }

                    @Override
                    public void onBuildingRequestFinished(String resultCode, Object building, Object user, Object users, Object circuit, Object img) {

                    }

                    @Override
                    public void onCommunityRequestFinished(String resultCode, Object community, Object user, Object users, Object circuit, Object img) {

                    }
                }, true);




    }

    private void setImage(List<MyImageVO> imgModel) {
        loader = ImageLoader.getInstance();
        options = new DisplayImageOptions.Builder()
                .showImageForEmptyUri(R.mipmap.img_mygoempty_nor3x)
                .showImageOnFail(R.mipmap.img_mygoempty_nor3x).cacheInMemory(true)
                .cacheOnDisc(true).displayer(new RoundedBitmapDisplayer(0))
                .build();
        List<String> imgs = new ArrayList<>();
        for (MyImageVO vo : imgModel) {
            if (vo.getCover() != 1) {
                imgs.add(vo.getPath3());
            }
        }
        viewPager = (ViewPager) findViewById(R.id.viewPager_things_all_img);
        mImageViews = new ImageView[imgs.size()];
        for (int i = 0; i < imgs.size(); i++) {
            final ImageView imageView = new ImageView(this);
            mImageViews[i] = imageView;

            loader.displayImage(imgs.get(i), imageView, new ImageLoadingListener() {
                @Override
                public void onLoadingStarted(String s, View view) {
                    imageView.setImageResource(R.mipmap.img_mygoempty_nor3x);
                }

                @Override
                public void onLoadingFailed(String s, View view, FailReason failReason) {
                    imageView.setImageResource(R.mipmap.img_mygoempty_nor3x);
                }

                @Override
                public void onLoadingComplete(String s, View view, Bitmap bitmap) {
                    imageView.setScaleType(ImageView.ScaleType.FIT_XY);
                }

                @Override
                public void onLoadingCancelled(String s, View view) {

                }
            });
        }

        viewPager.setAdapter(new ThingsCarportDetailActivity.MyAdapter());
        txtImgSize.setText(1 + "/" + mImageViews.length);
        viewPager.setCurrentItem(0);
        viewpagerListener();
        //设置ViewPager的默认项, 设置为长度的100倍，这样子开始就能往左滑动  
        //viewPager.setCurrentItem((mImageViews.length)*100);
    }

    private void viewpagerListener() {
        viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {

            @Override
            public void onPageSelected(int arg0) {
                txtImgSize.setText((arg0 + 1) + "/" + mImageViews.length);
            }

            @Override
            public void onPageScrolled(int arg0, float arg1, int arg2) {

            }

            @Override
            public void onPageScrollStateChanged(int arg0) {

            }
        });
    }

    class MyAdapter extends PagerAdapter {

        @Override
        public int getCount() {
            return mImageViews.length;
        }

        @Override
        public boolean isViewFromObject(View arg0, Object arg1) {
            return arg0 == arg1;
        }

        @Override
        public void destroyItem(View container, int position, Object object) {
            ((ViewPager) container).removeView(mImageViews[position % mImageViews.length]);
        }

        /**
         * 载入图片进去，用当前的position 除以 图片数组长度取余数是关键
         */
        @Override
        public Object instantiateItem(View container, int position) {
            ((ViewPager) container).addView(mImageViews[position % mImageViews.length], 0);
            return mImageViews[position % mImageViews.length];
        }

    }

    private void setThingsInfo(RentVO propertyModel) {
        txtPurpose.setText(propertyModel.getPurpose());
        txtName.setText(propertyModel.getName());
        txtAddr.setText(propertyModel.getAddr());
        txtSalePriceTitle.setText("售價");
        txtSaleprice.setText(propertyModel.getSaleprice() + " 萬");
     //   txtAreaTitlie.setText("坪數");
        txtArea.setText(propertyModel.getLawnarea() + " 坪");
    //    txtStoreyTitle.setText("樓層");
        txtStorey.setText(propertyModel.getStorey());
     //   txtCarpotHaveTitel.setText("車位");
        txtCarpotHave.setText(propertyModel.getCartport_have() == 0 ? "無" : "有");
    //    txtLiftTitle.setText("電梯");
        txtLift.setText(String.valueOf(propertyModel.getLift()));
     //   txtFeeTitle.setText("管理費");
        txtFee.setText(propertyModel.getFee() + "元/坪");
     //   txtFittingTitle.setText("裝修");
        txtFitting.setText(propertyModel.getFitting());
    //    txtCompletedateTitle.setText("完工日期");
        txtCompletedate.setText(propertyModel.getCompleteyear());
        txtType.setText(propertyModel.getPurpose());
        getDirection(propertyModel.getDirection(),txtDirection);
        txtCommunityName.setText(propertyModel.getCommunityname());

    }

    private void getThingsInfo(PropertyCommitVO propertyModel) {

        txtPurpose.setText(propertyModel.getProperty_purpose());
        txtName.setText(propertyModel.getProperty_name());
//        txtAddr.setText(propertyModel.getProperty());
 //       txtSalePriceTitle.setText("售價");
        txtSaleprice.setText(propertyModel.getProperty_saleprice() + " 萬");
//        txtAreaTitlie.setText("坪數");
        txtArea.setText(propertyModel.getProperty_ownershiparea() + " 坪");
        Log.e("propertyMtyoor()==",""+propertyModel.getProperty_minfloor());
//        txtStoreyTitle.setText("樓層");
        txtStorey.setText(String.valueOf(propertyModel.getProperty_minfloor()));
//        txtCarpotHaveTitel.setText("車位");
        txtCarpotHave.setText(propertyModel.getProperty_purpose());
//        txtLiftTitle.setText("電梯");
        txtLift.setText(String.valueOf(propertyModel.getProperty_lift()));
 //       txtFeeTitle.setText("管理費");
        txtFee.setText(propertyModel.getProperty_fee() + "元/坪");
 //       txtFittingTitle.setText("裝修");
        getFitting(propertyModel.getProperty_fitting());
//        txtFitting.setText(propertyModel.getProperty_fitting());
//        txtCompletedateTitle.setText("完工日期");
//        txtCompletedate.setText(propertyModel.getProperty_completeyear());
        txtType.setText(propertyModel.getProperty_purpose());
        getDirection(propertyModel.getProperty_direction(),txtDirection);
        txtCommunityName.setText(String.valueOf(propertyModel.getProperty_community()));



    }

    private void setUserInfo(UserVO userVO) {
        txtContact.setText(userVO.getName() + " " + userVO.getTel());
    }

    //配置
    private void setshopequip(String shopequip){

        LinearLayout ll_shopequip_one= (LinearLayout) findViewById(R.id.ll_shopequip_one);
        TextView txt_shopequip_noe = (TextView)findViewById(R.id.txt_shopequip_noe);
        TextView txt_shopequip_two = (TextView)findViewById(R.id.txt_shopequip_two);
        TextView txt_shopequip_three = (TextView)findViewById(R.id.txt_shopequip_three);
        TextView txt_shopequip_four = (TextView)findViewById(R.id.txt_shopequip_four);
//
        LinearLayout ll_shopequip_two= (LinearLayout) findViewById(R.id.ll_shopequip_two);
        LinearLayout ll_split = (LinearLayout) findViewById(R.id.ll_split);
        TextView txt_shopequip_one = (TextView)findViewById(R.id.txt_shopequip_one);
        TextView txt_shopequip_ttwo = (TextView)findViewById(R.id.txt_shopequip_ttwo);
        TextView txt_shopequip_tthree = (TextView)findViewById(R.id.txt_shopequip_tthree);
        TextView txt_shopequip_tfour = (TextView)findViewById(R.id.txt_shopequip_tfour);



        Log.e("propertyModoopequip()",""+shopequip);
        if(!StringUtil.isBlank(shopequip)){
            Log.e("propertyModoopequip()","111111111111112222222");
            String[] equip = shopequip.split(",");
//            LinearLayout content1,content2 =null;
            if(equip.length==1){
                txt_shopequip_two.setVisibility(View.GONE);
                txt_shopequip_three.setVisibility(View.GONE);
                txt_shopequip_four.setVisibility(View.GONE);

                ll_shopequip_two.setVisibility(View.GONE);

            }
            else if(equip.length==2){
                txt_shopequip_three.setVisibility(View.GONE);
                txt_shopequip_four.setVisibility(View.GONE);

                ll_shopequip_two.setVisibility(View.GONE);
            }
            else if(equip.length==3){
                txt_shopequip_four.setVisibility(View.GONE);

                ll_shopequip_two.setVisibility(View.GONE);
            }
            else if(equip.length==4){
                ll_shopequip_two.setVisibility(View.GONE);
            }
            else if(equip.length==5){
                txt_shopequip_ttwo.setVisibility(View.GONE);
                txt_shopequip_tthree.setVisibility(View.GONE);
                txt_shopequip_tfour.setVisibility(View.GONE);
            }
            else if(equip.length==6){
                txt_shopequip_tthree.setVisibility(View.GONE);
                txt_shopequip_tfour.setVisibility(View.GONE);
            }
            else if(equip.length==7){
                txt_shopequip_tfour.setVisibility(View.GONE);
            }
            if(equip.length<5){
                //  ll_shopequip_one.removeAllViews();
                ll_shopequip_two.setVisibility(View.GONE);
                for(int i=0;i<equip.length;i++) {
                    Log.e("propertyModoopequip()",""+equip[i]);
                    if (!StringUtil.isBlank(equip[i])) {
                        if(i==0){
                            txt_shopequip_noe.setText(initShopequip(Integer.parseInt(equip[i])));
                        }
                        else if(i==1){
                            if(StringUtil.isBlank(equip[i])){
                                txt_shopequip_two.setVisibility(View.GONE);
                            }
                            else {
                                txt_shopequip_two.setText(initShopequip(Integer.parseInt(equip[i])));
                            }

                        }
                        else if(i==2){
                            if(StringUtil.isBlank(equip[i])){
                                txt_shopequip_three.setVisibility(View.GONE);
                            }
                            else {
                                txt_shopequip_three.setText(initShopequip(Integer.parseInt(equip[i])));
                            }

                        }
                        else if(i==3){
                            if(StringUtil.isBlank(equip[i])){
                                txt_shopequip_four.setVisibility(View.GONE);
                            }
                            else {
                                txt_shopequip_four.setText(initShopequip(Integer.parseInt(equip[i])));
                            }

                        }

                    }

                }

            }
            else{
                ll_shopequip_two.setVisibility(View.VISIBLE);
                for(int i=0;i<equip.length;i++) {

                    if (!StringUtil.isBlank(equip[i])) {
                        if(i==0){

                            if(StringUtil.isBlank(equip[i])){
                                txt_shopequip_noe.setVisibility(View.GONE);
                            }
                            else {
                                txt_shopequip_noe.setText(initShopequip(Integer.parseInt(equip[i])));
                            }
                        }
                        else if(i==1){
                            if(StringUtil.isBlank(equip[i])){
                                txt_shopequip_two.setVisibility(View.GONE);
                            }
                            else {
                                txt_shopequip_two.setText(initShopequip(Integer.parseInt(equip[i])));
                            }

                        }
                        else if(i==2){
                            if(StringUtil.isBlank(equip[i])){
                                txt_shopequip_three.setVisibility(View.GONE);
                            }
                            else {
                                txt_shopequip_three.setText(initShopequip(Integer.parseInt(equip[i])));
                            }

                        }
                        else if(i==3){
                            if(StringUtil.isBlank(equip[i])){
                                txt_shopequip_four.setVisibility(View.GONE);
                            }
                            else {
                                txt_shopequip_four.setText(initShopequip(Integer.parseInt(equip[i])));
                            }

                        }
                        else if(i==4){

                            if(StringUtil.isBlank(equip[i])){
                                txt_shopequip_one.setVisibility(View.GONE);
                            }
                            else {
                                txt_shopequip_one.setText(initShopequip(Integer.parseInt(equip[i])));
                            }
                        }
                        else if(i==5){

                            if(StringUtil.isBlank(equip[i])){
                                txt_shopequip_ttwo.setVisibility(View.GONE);
                            }
                            else {
                                txt_shopequip_ttwo.setText(initShopequip(Integer.parseInt(equip[i])));
                            }
                        }
                        else if(i==6){

                            if(StringUtil.isBlank(equip[i])){
                                txt_shopequip_tthree.setVisibility(View.GONE);
                            }
                            else {
                                txt_shopequip_tthree.setText(initShopequip(Integer.parseInt(equip[i])));
                            }
                        }
                        else if(i==7){

                            if(StringUtil.isBlank(equip[i])){
                                txt_shopequip_tfour.setVisibility(View.GONE);
                            }
                            else {
                                txt_shopequip_tfour.setText(initShopequip(Integer.parseInt(equip[i])));
                            }
                        }


                    }

                }

            }

        }



    }

    private String initShopequip(int shopequip){
        String equip = "";
        if(shopequip==1){
            equip="客梯";
        }
        else if(shopequip==2){
            equip="扶梯";
        }
        else if(shopequip==3){
            equip="暖氣";
        }
        else if(shopequip==4){
            equip="停車位";
        }
        else if(shopequip==5){
            equip="水";
        }
        else if(shopequip==6){
            equip="天然氣";
        }
        else if(shopequip==7){
            equip="網路";
        }
        return  equip;
    }


    private void getFitting(int property_fitting){

        //裝修
        switch (property_fitting) {
            case 1:
                txtFitting.setText("毛坯");
                break;
            case 2:
                txtFitting.setText("普通裝修");
                break;
            case 3:
                txtFitting.setText("精裝修");
                break;
            case 4:
                txtFitting.setText("豪華裝修");
                break;
            default:
                break;
        }

    }

    private void getDirection(int direction,TextView txtDirection) {
        switch (direction) {
            case 1:
                txtDirection.setText("座北朝南");
                break;
            case 2:
                txtDirection.setText("座南朝北");
                break;
            case 3:
                txtDirection.setText("座西朝東");
                break;
            case 4:
                txtDirection.setText("座東朝西");
                break;
            case 5:
                txtDirection.setText("座東北朝西南");
                break;
            case 6:
                txtDirection.setText("座東南朝西北");
                break;
            case 7:
                txtDirection.setText("座西南朝東北");
                break;
            case 8:
                txtDirection.setText("座西北朝東南");
                break;
            case 9:
                txtDirection.setText("其他");
                break;
            default:
                break;
        }
    }

    private void createChildLinearLayout(final RentVO vo, final int i) {
        View view = mInflater.inflate(R.layout.item_things_detail_horizontalscrollview,linear, false);
        SimpleDraweeView imgView = (SimpleDraweeView) view.findViewById(R.id.img_things_horizontalscrollview);
        imgView.setImageURI(vo.getImg());
        TextView text1 = (TextView) view.findViewById(R.id.text_things_horizontalscrollview_1);
        text1.setText(vo.getName());
        TextView text2 = (TextView) view.findViewById(R.id.text_things_horizontalscrollview_2);
        text2.setText("NT$ "+vo.getSaleprice()+"/萬");
        TextView text3 = (TextView) view.findViewById(R.id.text_things_horizontalscrollview_3);
        text3.setText("坪數:"+vo.getLawnarea()+" 坪");
        TextView text4 = (TextView) view.findViewById(R.id.text_things_horizontalscrollview_4);
        text4.setText("層樓:"+vo.getStorey());
        linear.addView(view);
        view.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String param ="?seq="+vo.getSeq();
                initDetailRequest(param);
                httpThingsModel.requestThings();
            }
        });
    }

    @Override
    public void onMapReady(GoogleMap googleMap) {
        LatLng positon = new LatLng(25.04094, 121.45502);
        googleMap.addMarker(new MarkerOptions().position(positon).title(""));
        googleMap.moveCamera(CameraUpdateFactory.newLatLng(positon));
        GoogleMapOptions options = new GoogleMapOptions().liteMode(true);

    }

}
